package com.example.teamilkmall.controller;

import com.example.teamilkmall.controller.vo.ResultVO;
import com.example.teamilkmall.entity.CustomerInfo;
import com.example.teamilkmall.service.CustomerInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author czl
 * @Date 2025-01-07
 */
@RestController
@RequestMapping("/customerInfo")
public class CustomerInfoController extends BaseController{
    
    private final CustomerInfoService customerInfoService;

    public CustomerInfoController(CustomerInfoService customerInfoService) {
        this.customerInfoService = customerInfoService;
    }

    @GetMapping("/listCustomerInfo")
    public ResultVO<PageInfo<CustomerInfo>> listCustomerInfo(Integer limit, Integer page, String name){
        PageInfo<CustomerInfo> pageInfo = customerInfoService.listCustomerInfo(limit, page, name);
        return success(pageInfo);
    }

    @PostMapping("/updateCustomerInfo")
    public ResultVO updateCustomerInfo(CustomerInfo customerInfo){
        customerInfoService.updateCustomerInfo(customerInfo);
        return success();
    }

    @PostMapping("/deloneCustomerInfo")
    public ResultVO deloneCustomerInfo(Integer id){
        customerInfoService.deloneCustomerInfo(id);
        return success();
    }

    @PostMapping("/addCustomerInfo")
    public ResultVO addCustomerInfo(CustomerInfo customerInfo){
        customerInfoService.addCustomerInfo(customerInfo);
        return success();
    }

    @PostMapping("/listCustomerInfoAll")
    public ResultVO<List<CustomerInfo>> getCustomerInfoList(){
        return success(customerInfoService.listCustomerInfoAll());
    }

}
